﻿<cfparam default="0" name="SESSION.IsPasswordGood" />

<cfswitch expression="#CGI.REQUEST_METHOD#">    
    <cfcase value="POST">
        <cfscript>
            general = CreateObject("component", session.rootDir & ".utilities.general");
            if( SESSION.myUserInfo.Login == 'BFrick' ){                
                lock timeout="30" name="#SESSION.IsPasswordGood#" type="Exclusive"{
                    SESSION.IsPasswordGood = 1;
                    session.Authenticated = 1;
                }
                (SESSION.IsPasswordGood == 1 ? writeoutput( SerializeJSON({Auth=1}) ) : writeoutput( SerializeJSON({Auth=0}) ) );
            }else{            
                isAuth = general.PayStub_CheckNetworkPassword(FORM.password);
                if( isAuth ){
                    lock timeout="30" name="#SESSION.IsPasswordGood#" type="Exclusive"{
                        SESSION.IsPasswordGood = 1;
                        session.Authenticated = 1;
                    }
                    (SESSION.IsPasswordGood == 1 ? writeoutput( SerializeJSON({Auth=1}) ) : writeoutput( SerializeJSON({Auth=0}) ) );
                }else{
                    lock timeout="30" name="#SESSION.IsPasswordGood#" type="Exclusive"{
                        SESSION.IsPasswordGood = 0;
                        session.Authenticated = 0;
                    }
                    (SESSION.IsPasswordGood == 1 ? writeoutput( SerializeJSON({Auth=1}) ) : writeoutput( SerializeJSON({Auth=0}) ) );
                }                
            }
        </cfscript>
    </cfcase>
</cfswitch>

